package demo;

public class Demo08 {
    public static void main(String[] args) {
        byte[] bytes = encode(232233);
        int n = decode(bytes);
        System.out.println(n);

    }
    public static byte[] encode(int num){
        int b1 = (num>>>24) & 0xff;
        int b2 = (num>>>16) & 0xff;
        int b3 = (num>>>8) & 0xff;
        int b4 = num & 0xff;
        return new byte[]{(byte)b1,(byte)b2,(byte)b3,(byte)b4};
    }

    public static int decode(byte[] bytes){
        int b1 = bytes[0] & 0xff;
        int b2 = bytes[1] & 0xff;
        int b3 = bytes[2] & 0xff;
        int b4 = bytes[3] & 0xff;
        return (b1<<24) | (b2<<16) | (b3<<8) | b4;
    }

}
